# -*- coding: utf-8 -*-
"""
-------------------------------------------------
  File Name：   My_Combox
  Description :
  Author :    崔术森
  Eamil  :    deer_cui@163.com
  date：     2021/11/9
-------------------------------------------------
  Change Activity:
          2021/11/9:
-------------------------------------------------
"""
__author__ = '崔术森'

from PyQt5 import QtGui
from PyQt5.QtCore import pyqtSignal
from PyQt5.QtWidgets import QComboBox, QListView


class My_ComboBox(QComboBox):
    clicked = pyqtSignal()

    def __init__(self):
        QComboBox.__init__(self)
        listView = QListView()
        self.setView(listView)
        return

    def mouseReleaseEvent(self, QMouseEvent):
        self.showItems()

    def showPopup(self):
        # self.popupAboutToBeShown.emit()
        # prevent show popup, manually call it in mouse release event
        pass

    def showItems(self):
        super(My_ComboBox, self).showPopup()

    def mousePressEvent(self, QMouseEvent):
        self.clicked.emit()

    # 可在外部与槽函数连接
    def connect_customized_slot(self, func):
        self.clicked.connect(func)
